﻿//========================================
// All rights reserved (C) 2017-2100
// CLR 版本：	4.0.30319.42000
// 命名空间:	Transport
// 文 件 名：	Program
// 作    者：	WooG
// 联系方式：	wooglle@163.com
// 创建时间：	2017/9/27 14:46:31
//========================================
using Common;
using System;
using System.Diagnostics;
using System.Threading;

namespace Transport
{
    class Program
    {
        internal static string[] Args = null;
        [STAThread]
        static void Main(string[] args)
        {
            //////判断服务是否开启//////
            
            //////判断服务是否开启//////
            if (args.Length > 0)
            {
                Args = args;
            }
            MainWindow tra = new MainWindow();
            //tra.arguments = Args;
            tra.ShowDialog();
        }

        private bool StartService()
        {
            string serviceName = "SFJDService";
            ServiceHelper server = new ServiceHelper();
            if (!server.IsServiceIsExisted(serviceName))
            {
                return true;
            }
            else
            {
                if (!server.IsServiceStart(serviceName))
                {
                    try
                    {
                        server.StartService(serviceName);
                    }
                    catch
                    {
                        return true;
                    }
                    if (!server.IsServiceStart(serviceName))
                    {
                        Process p = new Process();
                        p.StartInfo.FileName = Environment.CurrentDirectory + "\\SFJDManagement.exe";
                        p.Start();
                        for (int i = 0; i < 10; i++)
                        {
                            if (!server.IsServiceStart(serviceName))
                            {
                                Thread.Sleep(300);
                            }
                        }
                    }
                }
            }
            if (!server.IsServiceStart(serviceName))
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
